Produced by Araxis Merge on 2023-03-13 03:00:44 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Porto v4.0.4/Porto Theme/app/code/Mageplaza/LayeredNavigation/view/frontend/web/js/view | layer.js | 2021-04-19 08:08:50 +0000 |
| 2 | Porto v4.0.5/Porto Theme/app/code/Mageplaza/LayeredNavigation/view/frontend/web/js/view | layer.js | 2023-02-06 09:30:07 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 10 | 704 |
| Changed | 5 | 19 |
| Inserted | 3 | 5 |
| Removed | 1 | 1 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | /** | 1 | /** | |||
| 2 | * Mageplaza | 2 | * Mageplaza | |||
| 3 | * | 3 | * | |||
| 4 | * NOTICE OF LICENSE | 4 | * NOTICE OF LICENSE | |||
| 5 | * | 5 | * | |||
| 6 | * This source file is subject to the Mageplaza.com license sliderConfig is | 6 | * This source file is subject to the Mageplaza.com license sliderConfig is | |||
| 7 | * available through the world-wide-web at this URL: | 7 | * available through the world-wide-web at this URL: | |||
| 8 | * https://www.mageplaza.com/LICENSE.txt | 8 | * https://www.mageplaza.com/LICENSE.txt | |||
| 9 | * | 9 | * | |||
| 10 | * DISCLAIMER | 10 | * DISCLAIMER | |||
| 11 | * | 11 | * | |||
| 12 | * Do not edit or add to this file if you wish to upgrade this extension to newer | 12 | * Do not edit or add to this file if you wish to upgrade this extension to newer | |||
| 13 | * version in the future. | 13 | * version in the future. | |||
| 14 | * | 14 | * | |||
| 15 | * @category Mageplaza | 15 | * @category Mageplaza | |||
| 16 | * @package Mageplaza_LayeredNavigation | 16 | * @package Mageplaza_LayeredNavigation | |||
| 17 | * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | 17 | * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | |||
| 18 | * @license https://www.mageplaza.com/LICENSE.txt | 18 | * @license https://www.mageplaza.com/LICENSE.txt | |||
| 19 | */ | 19 | */ | |||
| 20 | 20 | |||||
| 21 | define([ | 21 | define([ | |||
| 22 | 'jquery', | 22 | 'jquery', | |||
| 23 | 'Mageplaza_AjaxLayer/js/action/submit-filter', | 23 | 'Mageplaza_AjaxLayer/js/action/submit-filter', | |||
| 24 | 'Magento_Catalog/js/price-utils', | 24 | 'Magento_Catalog/js/price-utils', | |||
| 25 | 'jquery-ui-modules/widget', | |||||
| 26 | 'accordion', | 25 | 'accordion', | |||
| 27 | 'productListToolbarForm' | 26 | 'productListToolbarForm', | |||
| 27 | 'jquery/jquery-ui' | |||||
| 28 | ], function ($, submitFilterAction, ultil) { | 28 | ], function ($, submitFilterAction, ultil) { | |||
| 29 | "use strict"; | 29 | "use strict"; | |||
| 30 | 30 | |||||
| 31 | $.widget('mageplaza.layer', $.mage.accordion, { | 31 | $.widget('mageplaza.layer', $.mage.accordion, { | |||
| 32 | options: { | 32 | options: { | |||
| 33 | openedState: 'active', | 33 | openedState: 'active', | |||
| 34 | collapsible: true, | 34 | collapsible: true, | |||
| 35 | multipleCollapsible: true, | 35 | multipleCollapsible: true, | |||
| 36 | animate: 200, | 36 | animate: 200, | |||
| 37 | mobileShopbyElement: '#layered-filter-block .filter-title [data-role=title]', | 37 | mobileShopbyElement: '#layered-filter-block .filter-title [data-role=title]', | |||
| 38 | collapsibleElement: '[data-role=ln_collapsible]', | 38 | collapsibleElement: '[data-role=ln_collapsible]', | |||
| 39 | header: '[data-role=ln_title]', | 39 | header: '[data-role=ln_title]', | |||
| 40 | content: '[data-role=ln_content]', | 40 | content: '[data-role=ln_content]', | |||
| 41 | isCustomerLoggedIn: false, | 41 | isCustomerLoggedIn: false, | |||
| 42 | isAjax: true, | 42 | isAjax: true, | |||
| 43 | params: [], | 43 | params: [], | |||
| 44 | active: [], | 44 | active: [], | |||
| 45 | checkboxEl: 'input[type=checkbox], input[type=radio]', | 45 | checkboxEl: 'input[type=checkbox], input[type=radio]', | |||
| 46 | sliderElementPrefix: '#ln_slider_', | 46 | sliderElementPrefix: '#ln_slider_', | |||
| 47 | sliderTextElementPrefix: '#ln_slider_text_' | 47 | sliderTextElementPrefix: '#ln_slider_text_' | |||
| 48 | }, | 48 | }, | |||
| 49 | 49 | |||||
| 50 | _create: function () { | 50 | _create: function () { | |||
| 51 | this.initActiveItems(); | 51 | this.initActiveItems(); | |||
| 52 | 52 | |||||
| 53 | this._super(); | 53 | this._super(); | |||
| 54 | 54 | |||||
| 55 | this.initProductListUrl(); | 55 | this.initProductListUrl(); | |||
| 56 | this.initObserve(); | 56 | this.initObserve(); | |||
| 57 | this.initSlider(); | 57 | this.initSlider(); | |||
| 58 | this.initWishlistCompare(); | 58 | this.initWishlistCompare(); | |||
| 59 | this.selectedAttr(); | 59 | this.selectedAttr(); | |||
| 60 | this.renderCategoryTree(); | 60 | this.renderCategoryTree(); | |||
| 61 | }, | 61 | }, | |||
| 62 | 62 | |||||
| 63 | initActiveItems: function () { | 63 | initActiveItems: function () { | |||
| 64 | var layerActives = this.options.active, | 64 | var layerActives = this.options.active, | |||
| 65 | actives = []; | 65 | actives = []; | |||
| 66 | if ($(".page-layout-1column").length){ | |||||
| 67 | this.options.multipleCollapsible = false; | |||||
| 68 | } | |||||
| 66 | 69 | |||||
| 67 | if (typeof window.layerActiveTabs !== 'undefined') { | 70 | if (typeof window.layerActiveTabs !== 'undefined') { | |||
| 68 | layerActives = window.layerActiveTabs; | 71 | layerActives = window.layerActiveTabs; | |||
| 69 | } | 72 | } | |||
| 70 | if (layerActives.length) { | 73 | if (layerActives.length) { | |||
| 71 | this.element.find('.filter-options-item').each(function (index) { | 74 | this.element.find('.filter-options-item').each(function (index) { | |||
| 72 | if (~$.inArray($(this).attr('attribute'), layerActives)) { | 75 | if (~$.inArray($(this).attr('attribute'), layerActives)) { | |||
| 73 | actives.push(index); | 76 | actives.push(index); | |||
| 74 | } | 77 | } | |||
| 75 | }); | 78 | }); | |||
| 76 | } | 79 | } | |||
| 77 | 80 | |||||
| 78 | this.options.active = actives; | 81 | this.options.active = actives; | |||
| 79 | 82 | |||||
| 80 | return this; | 83 | return this; | |||
| 81 | }, | 84 | }, | |||
| 82 | 85 | |||||
| 83 | initProductListUrl: function () { | 86 | initProductListUrl: function () { | |||
| 84 | var isProcessToolbar = false, | 87 | var isProcessToolbar = false, | |||
| 85 | isAjax = this.options.isAjax; | 88 | isAjax = this.options.isAjax; | |||
| 86 | $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) { | 89 | $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) { | |||
| 87 | if (isProcessToolbar) { | 90 | if (isProcessToolbar) { | |||
| 88 | return; | 91 | return; | |||
| 89 | } | 92 | } | |||
| 90 | if (isAjax) { | 93 | if (isAjax) { | |||
| 91 | isProcessToolbar = true; | 94 | isProcessToolbar = true; | |||
| 92 | } | 95 | } | |||
| 93 | 96 | |||||
| 94 | var urlPaths = this.options.url.split('?'), | 97 | var urlPaths = this.options.url.split('?'), | |||
| 95 | baseUrl = urlPaths[0], | 98 | baseUrl = urlPaths[0], | |||
| 96 | urlParams = urlPaths[1] ? urlPaths[1].split('&') : [], | 99 | urlParams = urlPaths[1] ? urlPaths[1].split('&') : [], | |||
| 97 | paramData = {}, | 100 | paramData = {}, | |||
| 98 | parameters; | 101 | parameters; | |||
| 99 | for (var i = 0; i < urlParams.length; i++) { | 102 | for (var i = 0; i < urlParams.length; i++) { | |||
| 100 | parameters = urlParams[i].split('='); | 103 | parameters = urlParams[i].split('='); | |||
| 101 | paramData[parameters[0]] = parameters[1] !== undefined | 104 | paramData[parameters[0]] = parameters[1] !== undefined | |||
| 102 | ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20')) | 105 | ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20')) | |||
| 103 | : ''; | 106 | : ''; | |||
| 104 | } | 107 | } | |||
| 105 | paramData[paramName] = paramValue; | 108 | paramData[paramName] = paramValue; | |||
| 106 | if (paramValue === defaultValue) { | 109 | if (paramValue === defaultValue) { | |||
| 107 | delete paramData[paramName]; | 110 | delete paramData[paramName]; | |||
| 108 | } | 111 | } | |||
| 109 | paramData = $.param(paramData); | 112 | paramData = $.param(paramData); | |||
| 110 | if (isAjax) { | 113 | if (isAjax) { | |||
| 111 | submitFilterAction(baseUrl + (paramData.length ? '?' + paramData : '')); | 114 | submitFilterAction(baseUrl + (paramData.length ? '?' + paramData : '')); | |||
| 112 | } else location.href = baseUrl + (paramData.length ? '?' + paramData : ''); | 115 | } else location.href = baseUrl + (paramData.length ? '?' + paramData : ''); | |||
| 113 | } | 116 | } | |||
| 114 | }, | 117 | }, | |||
| 115 | 118 | |||||
| 116 | initObserve: function () { | 119 | initObserve: function () { | |||
| 117 | var self = this; | 120 | var self = this; | |||
| 118 | var isAjax = this.options.isAjax; | 121 | var isAjax = this.options.isAjax; | |||
| 119 | 122 | |||||
| 120 | // fix browser back, forward button | 123 | // fix browser back, forward button | |||
| 121 | if (typeof window.history.replaceState === "function") { | 124 | if (typeof window.history.replaceState === "function") { | |||
| 122 | window.history.replaceState({url: document.URL}, document.title); | 125 | window.history.replaceState({url: document.URL}, document.title); | |||
| 123 | 126 | |||||
| 124 | setTimeout(function () { | 127 | setTimeout(function () { | |||
| 125 | window.onpopstate = function (e) { | 128 | window.onpopstate = function (e) { | |||
| 126 | if (e.state) { | 129 | if (e.state) { | |||
| 127 | submitFilterAction(e.state.url, 1); | 130 | submitFilterAction(e.state.url, 1); | |||
| 128 | } | 131 | } | |||
| 129 | }; | 132 | }; | |||
| 130 | }, 0) | 133 | }, 0) | |||
| 131 | } | 134 | } | |||
| 132 | 135 | |||||
| 133 | var pageElements = $('#layer-product-list').find('.pages a'); | 136 | var pageElements = $('#layer-product-list').find('.pages a'); | |||
| 134 | pageElements.each(function () { | 137 | pageElements.each(function () { | |||
| 135 | var el = $(this), | 138 | var el = $(this), | |||
| 136 | link = self.checkUrl(el.prop('href')); | 139 | link = self.checkUrl(el.prop('href')); | |||
| 137 | if (!link) { | 140 | if (!link) { | |||
| 138 | return; | 141 | return; | |||
| 139 | } | 142 | } | |||
| 140 | 143 | |||||
| 141 | el.bind('click', function (e) { | 144 | el.bind('click', function (e) { | |||
| 142 | e.stopPropagation(); | 145 | e.stopPropagation(); | |||
| 143 | e.preventDefault(); | 146 | e.preventDefault(); | |||
| 144 | if (isAjax) { | 147 | if (isAjax) { | |||
| 145 | submitFilterAction(link); | 148 | submitFilterAction(link); | |||
| 146 | } else location.href = link; | 149 | } else location.href = link; | |||
| 147 | }) | 150 | }) | |||
| 148 | }); | 151 | }); | |||
| 149 | 152 | |||||
| 150 | var currentElements = this.element.find('.filter-current a, .filter-actions a'); | 153 | var currentElements = this.element.find('.filter-current a, .filter-actions a'); | |||
| 151 | currentElements.each(function (index) { | 154 | currentElements.each(function (index) { | |||
| 152 | var el = $(this), | 155 | var el = $(this), | |||
| 153 | link = self.checkUrl(el.prop('href')); | 156 | link = self.checkUrl(el.prop('href')); | |||
| 154 | if (!link) { | 157 | if (!link) { | |||
| 155 | return; | 158 | return; | |||
| 156 | } | 159 | } | |||
| 157 | 160 | |||||
| 158 | el.bind('click', function (e) { | 161 | el.bind('click', function (e) { | |||
| 159 | e.stopPropagation(); | 162 | e.stopPropagation(); | |||
| 160 | e.preventDefault(); | 163 | e.preventDefault(); | |||
| 161 | if (isAjax) { | 164 | if (isAjax) { | |||
| 162 | submitFilterAction(link); | 165 | submitFilterAction(link); | |||
| 163 | } else { | 166 | } else { | |||
| 164 | location.href = link; | 167 | location.href = link; | |||
| 165 | } | 168 | } | |||
| 166 | }); | 169 | }); | |||
| 167 | }); | 170 | }); | |||
| 168 | 171 | |||||
| 169 | var optionElements = this.element.find('.filter-options a'); | 172 | var optionElements = this.element.find('.filter-options a'); | |||
| 170 | optionElements.each(function (index) { | 173 | optionElements.each(function (index) { | |||
| 171 | var el = $(this), | 174 | var el = $(this), | |||
| 172 | link = self.checkUrl(el.prop('href')); | 175 | link = self.checkUrl(el.prop('href')); | |||
| 173 | if (!link) { | 176 | if (!link) { | |||
| 174 | return; | 177 | return; | |||
| 175 | } | 178 | } | |||
| 176 | 179 | |||||
| 177 | el.bind('click', function (e) { | 180 | el.bind('click', function (e) { | |||
| 178 | if (el.hasClass('swatch-option-link-layered')) { | 181 | if (el.hasClass('swatch-option-link-layered')) { | |||
| 179 | self.selectSwatchOption(el); | 182 | self.selectSwatchOption(el); | |||
| 180 | } else { | 183 | } else { | |||
| 181 | var checkboxEl = el.siblings(self.options.checkboxEl); | 184 | var checkboxEl = el.siblings(self.options.checkboxEl); | |||
| 182 | checkboxEl.prop('checked', !checkboxEl.prop('checked')); | 185 | checkboxEl.prop('checked', !checkboxEl.prop('checked')); | |||
| 183 | } | 186 | } | |||
| 184 | 187 | |||||
| 185 | e.stopPropagation(); | 188 | e.stopPropagation(); | |||
| 186 | e.preventDefault(); | 189 | e.preventDefault(); | |||
| 187 | self.ajaxSubmit(link); | 190 | self.ajaxSubmit(link); | |||
| 188 | }); | 191 | }); | |||
| 189 | 192 | |||||
| 190 | var checkbox = el.siblings(self.options.checkboxEl); | 193 | var checkbox = el.siblings(self.options.checkboxEl); | |||
| 191 | checkbox.bind('click', function (e) { | 194 | checkbox.bind('click', function (e) { | |||
| 192 | e.stopPropagation(); | 195 | e.stopPropagation(); | |||
| 193 | self.ajaxSubmit(link); | 196 | self.ajaxSubmit(link); | |||
| 194 | }); | 197 | }); | |||
| 195 | }); | 198 | }); | |||
| 196 | 199 | |||||
| 197 | var swatchElements = this.element.find('.swatch-attribute'); | 200 | var swatchElements = this.element.find('.swatch-attribute'); | |||
| 198 | swatchElements.each(function (index) { | 201 | swatchElements.each(function (index) { | |||
| 199 | var el = $(this); | 202 | var el = $(this); | |||
| 200 | var attCode = el.attr('attribute-code'); | 203 | var attCode = el.attr('attribute-code'); | |||
| 201 | if (attCode) { | 204 | if (attCode) { | |||
| 202 | if (self.options.params.hasOwnProperty(attCode)) { | 205 | if (self.options.params.hasOwnProperty(attCode)) { | |||
| 203 | var attValues = self.options.params[attCode].split(","); | 206 | var attValues = self.options.params[attCode].split(","); | |||
| 204 | var swatchOptions = el.find('.swatch-option'); | 207 | var swatchOptions = el.find('.swatch-option'); | |||
| 205 | swatchOptions.each(function (option) { | 208 | swatchOptions.each(function (option) { | |||
| 206 | var elOption = $(this); | 209 | var elOption = $(this); | |||
| 207 | if ($.inArray(elOption.attr('option-id'), attValues) !== -1) { | 210 | if ($.inArray(elOption.attr('option-id'), attValues) !== -1) { | |||
| 208 | elOption.addClass('selected'); | 211 | elOption.addClass('selected'); | |||
| 209 | } | 212 | } | |||
| 210 | }); | 213 | }); | |||
| 211 | } | 214 | } | |||
| 212 | } | 215 | } | |||
| 213 | }); | 216 | }); | |||
| 214 | }, | 217 | }, | |||
| 215 | 218 | |||||
| 216 | selectSwatchOption: function (el) { | 219 | selectSwatchOption: function (el) { | |||
| 217 | var childEl = el.find('.swatch-option'); | 220 | var childEl = el.find('.swatch-option'); | |||
| 218 | if (childEl.hasClass('selected')) { | 221 | if (childEl.hasClass('selected')) { | |||
| 219 | childEl.removeClass('selected'); | 222 | childEl.removeClass('selected'); | |||
| 220 | } else { | 223 | } else { | |||
| 221 | childEl.addClass('selected'); | 224 | childEl.addClass('selected'); | |||
| 222 | } | 225 | } | |||
| 223 | }, | 226 | }, | |||
| 224 | 227 | |||||
| 225 | initSlider: function () { | 228 | initSlider: function () { | |||
| 226 | var self = this, | 229 | var self = this, | |||
| 227 | slider = this.options.slider; | 230 | slider = this.options.slider; | |||
| 228 | 231 | |||||
| 229 | for (var code in slider) { | 232 | for (var code in slider) { | |||
| 230 | if (slider.hasOwnProperty(code)) { | 233 | if (slider.hasOwnProperty(code)) { | |||
| 231 | var sliderConfig = slider[code], | 234 | var sliderConfig = slider[code], | |||
| 232 | sliderElement = self.element.find(this.options.sliderElementPrefix + code), | 235 | sliderElement = self.element.find(this.options.sliderElementPrefix + code), | |||
| 233 | priceFormat = sliderConfig.hasOwnProperty('priceFormat') ? JSON.parse(sliderConfig.priceFormat) : null; | 236 | priceFormat = sliderConfig.hasOwnProperty('priceFormat') ? JSON.parse(sliderConfig.priceFormat) : null; | |||
| 234 | 237 | |||||
| 235 | if (sliderElement.length) { | 238 | if (sliderElement.length) { | |||
| 236 | sliderElement.slider({ | 239 | sliderElement.slider({ | |||
| 237 | range: true, | 240 | range: true, | |||
| 238 | min: sliderConfig.minValue, | 241 | min: sliderConfig.minValue, | |||
| 239 | max: sliderConfig.maxValue, | 242 | max: sliderConfig.maxValue, | |||
| 240 | values: [sliderConfig.selectedFrom, sliderConfig.selectedTo], | 243 | values: [sliderConfig.selectedFrom, sliderConfig.selectedTo], | |||
| 241 | slide: function (event, ui) { | 244 | slide: function (event, ui) { | |||
| 242 | self.displaySliderText(code, ui.values[0], ui.values[1], priceFormat); | 245 | self.displaySliderText(code, ui.values[0], ui.values[1], priceFormat); | |||
| 243 | }, | 246 | }, | |||
| 244 | change: function (event, ui) { | 247 | change: function (event, ui) { | |||
| 245 | self.ajaxSubmit(self.getSliderUrl(sliderConfig.ajaxUrl, ui.values[0], ui.values[1])); | 248 | self.ajaxSubmit(self.getSliderUrl(sliderConfig.ajaxUrl, ui.values[0], ui.values[1])); | |||
| 246 | } | 249 | } | |||
| 247 | }); | 250 | }); | |||
| 248 | } | 251 | } | |||
| 249 | self.displaySliderText(code, sliderConfig.selectedFrom, sliderConfig.selectedTo, priceFormat); | 252 | self.displaySliderText(code, sliderConfig.selectedFrom, sliderConfig.selectedTo, priceFormat); | |||
| 250 | } | 253 | } | |||
| 251 | } | 254 | } | |||
| 252 | }, | 255 | }, | |||
| 253 | 256 | |||||
| 254 | displaySliderText: function (code, from, to, format) { | 257 | displaySliderText: function (code, from, to, format) { | |||
| 255 | var textElement = this.element.find(this.options.sliderTextElementPrefix + code); | 258 | var textElement = this.element.find(this.options.sliderTextElementPrefix + code); | |||
| 256 | if (textElement.length) { | 259 | if (textElement.length) { | |||
| 257 | if (format !== null) { | 260 | if (format !== null) { | |||
| 258 | from = this.formatPrice(from, format); | 261 | from = this.formatPrice(from, format); | |||
| 259 | to = this.formatPrice(to, format); | 262 | to = this.formatPrice(to, format); | |||
| 260 | } | 263 | } | |||
| 261 | 264 | |||||
| 262 | textElement.html(from + ' - ' + to); | 265 | textElement.html(from + ' - ' + to); | |||
| 263 | } | 266 | } | |||
| 264 | }, | 267 | }, | |||
| 265 | 268 | |||||
| 266 | getSliderUrl: function (url, from, to) { | 269 | getSliderUrl: function (url, from, to) { | |||
| 267 | return url.replace('from-to', from + '-' + to); | 270 | return url.replace('from-to', from + '-' + to); | |||
| 268 | }, | 271 | }, | |||
| 269 | 272 | |||||
| 270 | formatPrice: function (value, format) { | 273 | formatPrice: function (value, format) { | |||
| 271 | return ultil.formatPrice(value, format); | 274 | return ultil.formatPrice(value, format); | |||
| 272 | }, | 275 | }, | |||
| 273 | 276 | |||||
| 274 | ajaxSubmit: function (submitUrl) { | 277 | ajaxSubmit: function (submitUrl) { | |||
| 275 | var isAjax = this.options.isAjax; | 278 | var isAjax = this.options.isAjax; | |||
| 276 | this.element.find(this.options.mobileShopbyElement).trigger('click'); | 279 | this.element.find(this.options.mobileShopbyElement).trigger('click'); | |||
| 277 | 280 | |||||
| 278 | if (isAjax) { | 281 | if (isAjax) { | |||
| 279 | return submitFilterAction(submitUrl); | 282 | return submitFilterAction(submitUrl); | |||
| 280 | } | 283 | } | |||
| 281 | location.href = submitUrl; | 284 | location.href = submitUrl; | |||
| 282 | }, | 285 | }, | |||
| 283 | 286 | |||||
| 284 | checkUrl: function (url) { | 287 | checkUrl: function (url) { | |||
| 285 | var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/; | 288 | var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/; | |||
| 286 | 289 | |||||
| 287 | return regex.test(url) ? url : null; | 290 | return regex.test(url) ? url : null; | |||
| 288 | }, | 291 | }, | |||
| 289 | 292 | |||||
| 290 | //Handling 'add to wishlist' & 'add to compare' event | 293 | //Handling 'add to wishlist' & 'add to compare' event | |||
| 291 | initWishlistCompare: function () { | 294 | initWishlistCompare: function () { | |||
| 292 | var isAjax = this.options.isAjax; | 295 | var isAjax = this.options.isAjax; | |||
| 293 | var isCustomerLoggedIn = this.options.isCustomerLoggedIn, | 296 | var isCustomerLoggedIn = this.options.isCustomerLoggedIn, | |||
| 294 | elClass = 'a.action.tocompare' + (isCustomerLoggedIn ? ',a.action.towishlist' : ''); | 297 | elClass = 'a.action.tocompare' + (isCustomerLoggedIn ? ',a.action.towishlist' : ''); | |||
| 295 | $(elClass).each(function () { | 298 | $(elClass).each(function () { | |||
| 296 | var el = $(this); | 299 | var el = $(this); | |||
| 300 | if (isAjax){ | |||||
| 297 | $(el).bind('click', function (e) { | 301 | $(el).bind('click', function (e) { | |||
| 298 | var dataPost = $(el).data('post'), | 302 | var dataPost = $(el).data('post'), | |||
| 299 | formKey = $('input[name="form_key"]').val() | 303 | formKey = $('input[name="form_key"]').val(), method = 'post'; | |||
| 300 | if (formKey) { | 304 | if (formKey) { | |||
| 301 | dataPost.data.form_key = formKey; | 305 | dataPost.data.form_key = formKey; | |||
| 302 | } | 306 | } | |||
| 303 | 307 | |||||
| 304 | var paramData = $.param(dataPost.data), | 308 | var paramData = $.param(dataPost.data), | |||
| 305 | url = dataPost.action + (paramData.length ? '?' + paramData : ''); | 309 | url = dataPost.action + (paramData.length ? '?' + paramData : ''); | |||
| 306 | 310 | |||||
| 307 | e.stopPropagation(); | 311 | e.stopPropagation(); | |||
| 308 | e.preventDefault(); | 312 | e.preventDefault(); | |||
| 309 | 313 | |||||
| 310 | if (isAjax && el.hasClass('towishlist')) { | 314 | if ( | |||
| 311 | submitFilterAction(url, true | 315 | submitFilterAction(url, true, method); | |||
| 312 | } else if (isAjax) { | 316 | } else | |||
| 313 | submitFilterAction(url | 317 | submitFilterAction(url, true, method); | |||
| 314 | } else location.href = url; | 318 | } | |||
| 315 | }); | 319 | }); | |||
| 320 | } | |||||
| 316 | }) | 321 | }) | |||
| 317 | }, | 322 | }, | |||
| 318 | 323 | |||||
| 319 | //Selected attribute color after page load. | 324 | //Selected attribute color after page load. | |||
| 320 | selectedAttr: function () { | 325 | selectedAttr: function () { | |||
| 321 | var filterCurrent = $('.layered-filter-block-container .filter-current .items .item .filter-value'); | 326 | var filterCurrent = $('.layered-filter-block-container .filter-current .items .item .filter-value'); | |||
| 322 | 327 | |||||
| 323 | filterCurrent.each(function(){ | 328 | filterCurrent.each(function(){ | |||
| 324 | var el = $(this), | 329 | var el = $(this), | |||
| 325 | colorLabel = el.html(), | 330 | colorLabel = el.html(), | |||
| 326 | colorAttr = $('.filter-options .filter-options-item .color .swatch-option-link-layered .swatch-option'); | 331 | swatchAttr = $('.filter-options .filter-options-item . | |||
| 327 | 332 | |||||
| 328 | colorAttr.each(function(){ | 333 | swatchAttr.each(function(){ | |||
| 329 | var elA = $(this); | 334 | var elA = $(this); | |||
| 330 | if(elA.attr('data-option-label') === colorLabel && !elA.hasClass('selected')){ | 335 | if(elA.attr('data-option-label') === colorLabel && !elA.hasClass('selected')){ | |||
| 331 | elA.addClass('selected'); | 336 | elA.addClass('selected'); | |||
| 332 | } | 337 | } | |||
| 333 | }); | 338 | }); | |||
| 334 | }); | 339 | }); | |||
| 335 | }, | 340 | }, | |||
| 336 | 341 | |||||
| 337 | renderCategoryTree: function () { | 342 | renderCategoryTree: function () { | |||
| 338 | var iconExpand = this.element.find('.filter-options .icon-expand'); | 343 | var iconExpand = this.element.find('.filter-options .icon-expand'); | |||
| 339 | 344 | |||||
| 340 | iconExpand.each(function () { | 345 | iconExpand.each(function () { | |||
| 341 | var el = $(this); | 346 | var el = $(this); | |||
| 342 | 347 | |||||
| 343 | el.nextAll('ol').each(function() { | 348 | el.nextAll('ol').each(function() { | |||
| 344 | if($(this).find('input[checked]').length !== 0 | 349 | if($(this).find('input[checked]').length !== 0 | |||
| 345 | && !$(this).prevAll('.icon-expand').hasClass('active') | 350 | && !$(this).prevAll('.icon-expand').hasClass('active') | |||
| 346 | ) { | 351 | ) { | |||
| 347 | $(this).show(); | 352 | $(this).show(); | |||
| 348 | $(this).prevAll('.icon-expand').toggleClass('active'); | 353 | $(this).prevAll('.icon-expand').toggleClass('active'); | |||
| 349 | } | 354 | } | |||
| 350 | }); | 355 | }); | |||
| 351 | 356 | |||||
| 352 | el.bind('click', function (e) { | 357 | el.bind('click', function (e) { | |||
| 353 | el.nextAll('ol').toggle(); | 358 | el.nextAll('ol').toggle(); | |||
| 354 | el.toggleClass('active'); | 359 | el.toggleClass('active'); | |||
| 355 | e.stopPropagation(); | 360 | e.stopPropagation(); | |||
| 356 | }); | 361 | }); | |||
| 357 | }); | 362 | }); | |||
| 358 | } | 363 | } | |||
| 359 | }); | 364 | }); | |||
| 360 | 365 | |||||
| 361 | return $.mageplaza.layer; | 366 | return $.mageplaza.layer; | |||
| 362 | }); | 367 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.